function publishCoxRegressResults(res,path,csvname,inputLabels,outcomeLabel)


%%%%%
% This function creates a csv file summarizing Cox regression results. 
%
% Inputs:
% res - output from the coxRegress.m
% path - string containing the path for the generated csv file
% csvname - string representing the csv file name
% inputLabels - 1D cell array of string labels of the input variables. should be in the same order as the b coefficients in res (note: don't include one for the constant term).
% outcomeLabel - string for the label of the outcome variable.
% 
% Written by Joon Lee, 2010
%%%%%


temp=cell(length(res.b)+9,5);

temp{1,1}='Outcome Variable:'; temp{1,2}=outcomeLabel;

temp{3,1}='N:'; temp{3,2}=res.N;
temp{4,1}='C:'; temp{4,2}=res.C;
temp{5,1}='Goodness-of-fit p-value:'; temp{5,2}=res.goodness_of_fit_p;
temp{6,1}='x-validation mean C:'; temp{6,2}=res.xval(1);
temp{7,1}='x-validation std C:'; temp{7,2}=res.xval(2);

temp{9,2}='Hazards Ratio'; temp{9,3}='95% Confidence Interval Lower Bound'; temp{9,4}='95% Confidence Interval Upper Bound'; temp{9,5}='p-value';
for i=1:length(res.b)
    temp{9+i,1}=inputLabels{i};
    temp{9+i,2}=exp(res.b(i));
    temp{9+i,3}=exp(-1.96.*res.stats.se(i)+res.b(i));
    temp{9+i,4}=exp(1.96.*res.stats.se(i)+res.b(i));
    temp{9+i,5}=res.stats.p(i);
end

cd(path)
cell2csv(csvname,temp);

